package xuegao.study.mall.order.controller;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xuegao.study.mall.common.model.oms.OmsCartItem;
import xuegao.study.mall.order.service.OmsCarItemService;

import java.util.List;

/**
 * 购物车相关信息
 */
@RestController
@RequestMapping(value = "/cart")
public class OmsCarItemController {

    @Autowired
    private OmsCarItemService omsCarItemService;

    @ApiOperation("将商品加入到购物车")
    @PostMapping(value = "/add")
    Boolean add(@RequestBody OmsCartItem cartItem) {
        return omsCarItemService.add(cartItem);
    }

    @ApiOperation("获取会员购物车列表")
    @GetMapping(value = "/list")
    List<OmsCartItem> list(@RequestParam Long memberId) {
        return omsCarItemService.list(memberId);
    }
}
